/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerz.states;

import java.util.Vector;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import towerz.system.BitmapFont;
import towerz.system.StateManager;

/**
 *
 * @author TimotiusNC
 */
public class StateLoading extends GameState {
	public StateLoading(Integer level){
		super(GameState.LOADING);
		
		//Save
		m_Level = level;
		
		//Initialize
		m_Painted		= false;
		m_LoadingImage	= BitmapFont.getFont(BitmapFont.TITLE).renderText("LOADING...");
	}

	public void update(long time, int keys) {
		//Super
		super.update(time, keys);
		
		//If already painted
		if (m_Painted) {
			//Create parameters
			Vector Parameters = new Vector();
			Parameters.addElement(m_Level);
			
			//Go to game play
			StateManager.instance().goTo(GameState.GAME, Parameters, true);
		}
	}

	public void draw(Graphics g) {
		//Super
		super.draw(g);
		
		//Draw return image
		g.drawImage(m_LoadingImage, 10, StateManager.instance().getHeight() - 16, Graphics.LEFT | Graphics.BOTTOM);
		
		//Painted
		m_Painted = true;
	}
	
	protected Integer	m_Level;
	protected boolean	m_Painted;
	protected Image		m_LoadingImage;
}
